#pragma once
#include <memory>
#include <map>
#include <mutex>
#include "ADecoder.h"

namespace Media{
    #define MAX_ENCODER_NUM 16
    class ADecoderManager{
    public:
        using Ptr = std::shared_ptr<ADecoderManager>;
        using EncChannel = int;
        using EncEnabled = bool;

        static Ptr Instance();
        ADecoderManager();
        ~ADecoderManager();

        bool CreateDecoder(ADecoder::Ptr& ptr);
        bool ReleaseDecoder(const ADecoder::Ptr& ptr);
        
    private:
        bool getAvailableChannel(EncChannel& channel);
        std::map<EncChannel, EncEnabled> m_encoders;
        std::recursive_mutex m_mux;
    };

}